package com.itheima.service.mongo.impl;

import com.itheima.domain.mongo.Audio;
import com.itheima.service.mongo.MakeFriendService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

@Service
public class MakeFriendServiceImpl implements MakeFriendService {
    @Autowired
    private MongoTemplate mongoTemplate;
    //保存语音
    @Override
    public void sendAudio(Audio audio) {
        audio.setCreated(System.currentTimeMillis());
        mongoTemplate.save(audio);
    }

    //查询语音
    @Override
    public List<Audio> findAudio() {
        Query query = new Query();

        List<Audio> audioList = mongoTemplate.find(query, Audio.class);
        return audioList;
    }
}
